<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="a.header.jsp" %>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head> 
 <body>
 <form id="sch-form" class="layui-form layui-form-pane" lay-filter="sch-form" οnsubmit="return false;">
<div class="layui-inline">
		<label class="layui-form-label">发起时间从</label>
		<div class="layui-input-block">
			<input name="beginTimeFrom" type="text" autocomplete="off" id="startTime" class="layui-input laydate">
		</div>
</div>
<div class="layui-inline">
		<label class="layui-form-label">发起时间至</label>
		<div class="layui-input-block">
			<input name="beginTimeTo" type="text" autocomplete="off" id="endTime" class="layui-input laydate">
		</div>
</div>
 
<div class="layui-btn-container" style="text-align: center;">
		<button class="layui-btn" lay-submit lay-filter="btn-sch" id="btn-sch" ><i class="icon-search"></i> 查询</button>
		<button class="layui-btn layui-btn-primary" id="btn-resert"  ><i class="icon-undo"></i> 重置</button>
</div>
</form>
<script>
layui.use(['laydate','layer'], function(){
  var laydate = layui.laydate;
  var layer = layui.layer;
  var $=layui.$;
  var nowTime=new Date();    
  var startTime=laydate.render({
  	elem:'#startTime',
  	type:'datetime',
  	format:'yyyy年MM月dd日HH时mm分',
  	value:nowTime,
  	btns: ['confirm'],
//   	min:'nowTime',
//   	max:'nowTime',//默认最大值为当前日期
  	done:function(value,date){
  		console.log(startTime)
//  		console.log(value); //得到日期生成的值，如：2017-08-18
//  	    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
  	    endTime.config.min={    	    		
  	    	year:date.year,
  	    	month:date.month-1,//关键
              date:date.date,
              hours:date.hours,
              minutes:date.minutes,
              seconds:date.seconds
  	    };
  	    
  	}
  })
  var endTime=laydate.render({
  	elem:'#endTime',
  	type:'datetime',
  	btns: ['confirm'],
//   	min:'nowTime',
  	done:function(value,date){
//  		console.log(value); //得到日期生成的值，如：2017-08-18
//  	    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}    	   
  	    startTime.config.max={
  	    		year:date.year-1,
//       	    	month:date.month-1,//关键
//                   date:date.date,
//                   hours:date.hours,
//                   minutes:date.minutes,
//                   seconds:date.seconds
  	    }
  	    
  	}
  })

//重置
$("#btn-resert").on("click",function(){
  		$("#sch-form")[0].reset(); 
  		endTime.config.min='1900-1-1';
  		startTime.config.max=endTime.config.max;
})
});
</script>
</body>

</html>